<!DOCTYPE html>
<?php
require 'common/mysqlCommon.php';
session_start();
?>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        
        <?php
        if(count($_POST)){
            //点击登录按钮之后的操作
            $username=$_POST["username"];
            $upwd=$_POST["upwd"];
            $loginstr="select * from user_infos where username='$username' and upwd='$upwd' ";
            $result= getDataSetBySQL($loginstr);
            if(count($result)>0){
                //通过用户名和密码可以找到记录
                $_SESSION["uid"]=$result[0]["uid"];
                echo "<script>alert('登录成功！');"
                    . "location='mysql001.php';</script>";
            }else{
                echo "<script>alert('用户名或者密码错误！');"
                    . "location='login.php';</script>";
            }
        }else{
            //页面第一次加载 显示登录按钮
          ?>
        <form action="login.php" method="post">
            <h1>用户登录</h1>
            用户名：<input type="text" name="username"/><br/>
            密 &nbsp;&nbsp;码：<input type="password" name="upwd"/><br/>
            <input  type="submit" value="登录"/>
            <input type="reset" value="取消"/>
        
        </form>
        <?php
        }
        ?>
    </body>
</html>
